package Lesson;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;

public class StreamLesson {
    public static void main(String[] args) {
        InputStream in = null;


        try {
            in = new FileInputStream("img/238c39bc3d2eaa4a51e8aa0f040907ec.jpg");
//
//            int data = 0;
//            //读取下一个字节，如果返回-1，表示读取完毕
//            while ((data=in.read())!=-1){
//                System.out.println(data);


            int len = 0;
            //缓冲区字节数
            byte[] array = new byte[1024];
            //将流中的数据读取到byte数组，返回当前读取的字节流，读取完毕，返回-1
            while ((len = in.read(array))!=-1){
                System.out.println(len);
            }
        }catch (IOException e){
            e.printStackTrace();
        }finally {
            try {
                in.close();
            }catch (Exception e){
                e.printStackTrace();
            }
        }

    }
}
